package org.rency.ues.engine.validator;

import org.rency.common.utils.validate.RegValidator;
import org.rency.ues.domain.request.CreateCertificationRequest;
import org.rency.ues.domain.response.CreateCertificationResponse;
import org.springframework.util.Assert;

/**
 * 创建证书参数校验
 *
 * @author: Created by user_rcy@163.com on 2016/07/31.
 * @version: V1.0.0
 * @since JDK 1.8
 */
public class CreateCertificationValidator extends AbstractRequestValidator<CreateCertificationRequest, CreateCertificationResponse>{

    @Override
    protected void validate(CreateCertificationRequest createCertificationRequest) {
        Assert.isTrue(RegValidator.isEmail(createCertificationRequest.getOrgiEmail()),"机构邮件地址格式不正确");
    }

    @Override
    protected String getValidatorName() {
        return "创建证书";
    }

    @Override
    protected CreateCertificationResponse success() {
        return CreateCertificationResponse.success();
    }

    @Override
    protected CreateCertificationResponse fail(String returnMessage) {
        return CreateCertificationResponse.fail(returnMessage);
    }
}
